#ifndef XPMDOC_DAL_DOC_ACCESS_H
#define XPMDOC_DAL_DOC_ACCESS_H
#include <string>
#include "model/XpmTermDoc.h"
#include "libjson.h"


namespace conex {
	class TermFactory;
	class TermControl;
}

class JSONNode;
namespace xpm {
	using namespace std;
	
	class DocAccess {
	public:
		DocAccess(conex::TermFactory* termFactory):  _termFactory(termFactory), _termControl(0) {}
		virtual int Load(XpmTermDoc& voc) = 0;
		virtual int Load(XpmTermDoc& voc, string signs) = 0;
		virtual bool Save(XpmTermDoc& voc, string& syntax) = 0;
		virtual string WriteTarget(XpmTermDoc& voc, string& syntax) = 0;
		void SetFilename(const char* filename);
		string GetFilename();
		bool SaveAs(XpmTermDoc& voc, const char* filename, string& syntax);
		void SetTermFactory(conex::TermFactory* termFactory);
		conex::TermFactory* termFactory();
	protected:
		conex::TermFactory* _termFactory;
		conex::TermControl* _termControl;
		string m_filename;
	};

	inline void DocAccess::SetFilename(const char* filename) {
		m_filename = filename;
	}

	inline string DocAccess::GetFilename() {
		return m_filename;
	}

	inline void DocAccess::SetTermFactory(conex::TermFactory* termFactory) {
		_termFactory = termFactory;
	}
	inline conex::TermFactory* DocAccess::termFactory() {
		return _termFactory;
	}
}
#endif